//
//  BLETransDeviceSingleton.h
//  AppsControl
//
//  Created by Kent Ng on 15/6/5.
//  Copyright (c) 2015年 peng xijin. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import "AppDelegate.h"

@class BLETransDeviceSingleton;
@protocol BLETransDeviceSingletonDelegate <NSObject>

- (void)BLETransDeviceSingletonBlueTooch:(BOOL)open;
- (void)BLETransDeviceSingletonConnected:(BOOL)connected;
- (void)BLETransDeviceSingletonDisConnected:(BOOL)connected;
- (void)BLETransDeviceSingletonSendReady:(BOOL)ready;

@end

@interface BLETransDeviceSingleton : NSObject<CBCentralManagerDelegate,CBPeripheralDelegate>

@property (nonatomic, strong) CBCentralManager *centralManager;
@property (strong, nonatomic) NSMutableArray *Characteristics;
@property (strong, nonatomic) CBCharacteristic *cbCharacteristcs;
@property (strong, nonatomic) CBPeripheral *discoveredPeripheral;
@property (strong, nonatomic) CBPeripheral *_Peripheral;
@property (strong, nonatomic) NSTimer *connectTimer;
@property (nonatomic, strong) NSMutableData *mutableData;
@property (nonatomic, assign) BOOL BleConnected;
@property (nonatomic, strong) UIWindow *window;
@property (nonatomic, strong) NSMutableArray *peripheralsArray;
@property (nonatomic, strong) NSMutableDictionary *tepHeatDic;
@property (nonatomic, weak) id<BLETransDeviceSingletonDelegate> delegate;
@property (nonatomic, strong) NSTimer *timer;
extern NSString *const unitHeadName;

+ (BLETransDeviceSingleton *)sharedInstance;

- (void)operation;

- (void)characteristc:(NSString *)uuid sendHostCmd:(Byte *)data lenght:(NSInteger)len;

- (void)AppGiveHUAck:(NSInteger)ackHead;

-(BOOL)connect:(CBPeripheral *)peripheral;

-(void)scan;

- (BOOL)disConnect;

- (void)reConnect;

- (void)secretKeySendTimeAlert:(NSInteger)timeAlert boundsAlert:(NSInteger)boundsAlert alertOn:(BOOL)on;

@end
